/*
 *  @author zhangqiang
 *  @data 2017/03/14
 *   办理列表
 * */

import React, { Component, PropTypes } from 'react';
import {} from 'antd-mobile';
import { ProcessList } from '../../components/process'
import Style from './index.scss'
import {connect} from 'react-redux';
import AlipayJSOperation from '../../utils/alipayJSOperation';
import {handlingList} from '../../actions/handlingAction';
import PageBar from '../../components/common/pageBar';

class handlingProgress extends Component {
    constructor(props) {
        super(props);
        this.state = {
            list: [], //列表数据
            msg: '', //最新状态
            orderInfo:{ //订单详情
                title: this.props.params.title, //主标题
            }
        }
        this.orderId = this.props.params.orderId; //订单ID
    }

    componentWillMount() {

    }

    //发送埋点信息
    sendMessage(type) {
        window.cxytj.recordUserBehavior({
            eventId: type,
            eventType: '2', //事件类型
            eventTime: '',  //触发时间
        });
    }

    componentDidMount() {
	    document.querySelector("title").innerHTML = "办理进度";
	    ///办理列表
	    this.props.dispatch(handlingList({ orderId: this.orderId,},(data)=>{
		    this.setState({
			    msg: data[0].handleMsg,
          list: data,
		    })
	    }))

	    //隐藏标题栏右键
	    AlipayJSOperation.setRightButtonStatus(false);
	    //设置标题
	    AlipayJSOperation.setTitle('办理进度');
	    //设置标题颜色
	    AlipayJSOperation.setBarColor('#2FB3FE');
        AlipayJSOperation.setLeftButtonStatus(()=>{
            this.sendMessage('insepection_handprogress_back');
        });

        this.sendMessage('inspection_handprogress_init');
    }

    componentWillUnmount() {
        AlipayJSOperation.removeLeftButtonEvent();
    }

    render() {
        let faileType = this.props.params.type == 'no'?false:true;
        return (
            <div className={Style.container}>
                <PageBar title="办理进度"/>
                <div className={Style.info}>
                    <div className={Style.title + ' text-overflow-one'}>{this.state.orderInfo.title}</div>
                </div>
                <div className={Style.content}>
                <ProcessList list={this.state.list} fail={faileType} />
                </div>
            </div>
        );
    }
}

handlingProgress.propTypes = {

};

handlingProgress.defaultProps = {
    
}

export default connect()(handlingProgress)
